/*
 * @Description: 回环检测任务管理
 * @Author: Sang Hao
 * @Date: 2021-10-18 16:12:48
 * @LastEditTime: 2021-10-27 11:11:23
 * @LastEditors: Sang Hao
 */
#ifndef LIDAR_SLAM_MAPPING_LOOP_CLOSING_LOOP_CLOSING_FLOW_HPP_
#define LIDAR_SLAM_MAPPING_LOOP_CLOSING_LOOP_CLOSING_FLOW_HPP_

#include <deque>
#include <ros/ros.h>
// subscriber
#include "lidar_slam/subscriber/key_frame_subscriber.hpp"
// publisher
#include "lidar_slam/publisher/loop_pose_publisher.hpp"
// loop_closing
#include "lidar_slam/mapping/loop_closing/loop_closing.hpp"

namespace lidar_slam {
class LoopClosingFlow {
private:
	/* data */
	// subscriber
	std::shared_ptr<KeyFrameSubscriber> key_frame_sub_ptr_;
	// publisher
	std::shared_ptr<LoopPosePublisher> loop_pose_pub_ptr_;
	// loop closing
	std::shared_ptr<LoopClosing> loop_closing_ptr_;

	std::deque<KeyFrame> key_frame_buff_;

	KeyFrame current_key_frame_;

private:
	/* 将实现都隐藏 */
	bool ReadData();
	bool HasData();
	bool ValidData();
	bool PublishData();

public:
	/* 对外只保留构造函数和Run函数 */
	LoopClosingFlow(ros::NodeHandle& nh);
	bool Run();
};

}



#endif